import pandas as pd

data ={
    "name": ["Lili", "Tom", "Jary", "Lili", "Tom", "Jary"],
    "source": [60, 61, 61, 71, 72,73],
}
df = pd.DataFrame(data)

# 分组
group_df = df.groupby("name")
# 打印分组名
group_names = group_df.groups.keys()
print(list(group_names))
'''
['Jary', 'Lili', 'Tom']
'''

# 筛选
tom_df = group_df.get_group("Tom")
print(tom_df)

# 排序
sort_source_group_df = group_df["source"].mean().sort_values(ascending=False)
print(sort_source_group_df)